package cn.iocoder.yudao.module.ai.controller.admin.busimodelparam;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.ai.controller.admin.busimodelparam.vo.*;
import cn.iocoder.yudao.module.ai.dal.dataobject.busimodelparam.BusiModelParamDO;
import cn.iocoder.yudao.module.ai.service.busimodelparam.BusiModelParamService;

@Tag(name = "管理后台 - 业务模型参数")
@RestController
@RequestMapping("/ai/modelParam")
@Validated
public class BusiModelParamController {

    @Resource
    private BusiModelParamService busiModelParamService;

    @PostMapping("/create")
    @Operation(summary = "创建业务模型参数")
    @PreAuthorize("@ss.hasPermission('ai:busi-model-param:create')")
    public CommonResult<Integer> createBusiModelParam(@Valid @RequestBody BusiModelParamSaveReqVO createReqVO) {
        return success(busiModelParamService.createBusiModelParam(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新业务模型参数")
    @PreAuthorize("@ss.hasPermission('ai:busi-model-param:update')")
    public CommonResult<Boolean> updateBusiModelParam(@Valid @RequestBody BusiModelParamSaveReqVO updateReqVO) {
        busiModelParamService.updateBusiModelParam(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除业务模型参数")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('ai:busi-model-param:delete')")
    public CommonResult<Boolean> deleteBusiModelParam(@RequestParam("id") Integer id) {
        busiModelParamService.deleteBusiModelParam(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得业务模型参数")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('ai:busi-model-param:query')")
    public CommonResult<BusiModelParamRespVO> getBusiModelParam(@RequestParam("id") Integer id) {
        BusiModelParamDO busiModelParam = busiModelParamService.getBusiModelParam(id);
        return success(BeanUtils.toBean(busiModelParam, BusiModelParamRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得业务模型参数分页")
    @PreAuthorize("@ss.hasPermission('ai:busi-model-param:query')")
    public CommonResult<PageResult<BusiModelParamRespVO>> getBusiModelParamPage(@Valid BusiModelParamPageReqVO pageReqVO) {
        PageResult<BusiModelParamDO> pageResult = busiModelParamService.getBusiModelParamPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, BusiModelParamRespVO.class));
    }


}